package com.bawei.doctor.util;

import java.util.List;

public class PageUtil<T> {
    private int page; //当前页
    private int size = 2; //分页单位
    private int pre;
    private int next;
    private int pages; //总页数
    private Long total;//总记录数
    private List<T> rows;

    public PageUtil() {
        System.out.println("无参构造");
    }

    public static void main(String[] args) {
        new PageUtil<>();
    }

    public PageUtil(int page, int size, Long total, List<T> rows) {
        this.page = page;
        this.size = size;
        //总页数  5条每页2条
        this.pages = (int) (total%size==0?total/size:total/size+1);
        //上一页
        this.pre = page>1?page-1:1;
        //下一页
        this.next = page<this.pages?page+1:this.pages;

        this.total = total;
        this.rows = rows;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getPre() {
        return pre;
    }

    public void setPre(int pre) {
        this.pre = pre;
    }

    public int getNext() {
        return next;
    }

    public void setNext(int next) {
        this.next = next;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
